﻿using Mp3Player;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KWindow.KPageCore
{
    public partial class PageControlBase
    {
        protected bool _voiceEnabled = false;

        protected string _voiceFileName = "";

        /// <summary>
        /// 开启窗体业务后即调用
        /// </summary>
        public void PlayWelcomeVoice()
        {
            if (_voiceEnabled)
            {
                CommonService.Speak(this, _voiceFileName);
            }
        }

        public void Speak(string info)
        {
            if (this.InvokeRequired)
            {
                Action<string> outdelegate = new Action<string>(Speak);
                this.BeginInvoke(outdelegate, new object[] { info });
                return;
            }
            CommonService.SpeakAsync(this, info);
        }

        public void Speak(List<string> infos)
        {
            if (this.InvokeRequired)
            {
                Action<List<string>> outdelegate = new Action<List<string>>(Speak);
                this.BeginInvoke(outdelegate, new object[] { infos });
                return;
            }
            CommonService.Speak(this, infos);
        }

        public void AddSpeakDoneEvent(QueueSpeakingDoneEventHandler done)
        {
            CommonService.AddSpeakDoneEvent(done);
        }

        public void AbortSpeak()
        {
            CommonService.AbortSpeak();
        }

        /// <summary>
        /// 处理问候音播报完成后的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void SpeakingDone(object sender, QueueSpeakingDoneEventArgs e)
        {
            //添加其他开始处理的代码

        }

    }
}
